<template>
  <div>
    <div class="bgBox">
      <img src="@/assets/old/image/manage/login/loginBg.jpg" alt="">
      <div class="loginInput">
        <p class="title">“G采通”系统管理后台</p>
        <ul class="inputItem">
          <li>
            <el-input placeholder="请输入内容" v-model="name">
              <template slot="prepend"><img src="@/assets/old/image/manage/login/person.png"></template>
            </el-input>
          </li>
          <li>
            <el-input placeholder="请输入内容" v-model="password">
              <template slot="prepend"><img src="@/assets/old/image/manage/login/lock.png"></template>
            </el-input>
            <el-button @click="login">登录</el-button>
          </li>
          <li class="warning">
            <p class="tipIcon"></p>
            <p>用户名或密码填写错误</p>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
import md5 from 'js-md5'
export default {
  name: 'OSSLogin',
  components: {

  },
  data () {
    return {
      name: '',
      password: '',
    }
  },
  mounted () {

  },
  methods: {
    login: function () {
      if (this.name && this.password) {
        this.$axios.post('/api/manage/admin/login',
          'name=' + this.name + '&password=' + md5(this.password.toString())).then(result => {
          if (result.success) {
            window.$adminInfo = result.result
            console.log('admin', result.result)
            this.saveAdminInfo(result.result)
            this.$router.push('/admin/Index')
          } else this.$message.error(result.desc)
        })
      }
    },
  },
}
</script>

<style lang="less" scoped>
  .bgBox {
    width: 100%;
    height: 100%;
  }

  .bgBox img {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
  }
  .loginInput {
    width: 100%;
    height: 275px;
    line-height: 50px;
    background: rgba(0, 0, 0, 0.5);
    position: absolute;
    top: 30%;
    left: 0;
    right: 0;
    bottom: 0%;
    z-index: 5;
  }
  .title {
    color: rgba(255, 255, 255, 1);
    font-size: 40px;
    text-align: center;
    font-family: SourceHanSansSC-regular;
    margin: 26px 0 17px 0;
  }

  .user, .lock {
    display: block;
    width: 22px;
    height: 22px;
    background: url('~@/assets/old/image/manage/login/person.png') no-repeat center center;
    background-size: 100% 100%;
    position: absolute;
    top: 6px;
    left: 135px;
    z-index: 3;
  }

  .inputItem {
    width: 465px;
    height: auto;
    margin: 0 auto;
  }

  .inputItem li:first-child {
    margin-top: 28px;
  }

  .inputItem .warning {
    display: none;
    margin-top: 0;
  }

</style>
